package main

import (
	"gitee.com/smallow/srpc/infrastructure/conf"
	"gitee.com/smallow/srpc/infrastructure/proto/pb"
	"gitee.com/smallow/srpc/infrastructure/server"
	"google.golang.org/grpc"
	"log"
	"net"
)

func main() {
	//1、监听
	listener, err := net.Listen("tcp", conf.GetConf().ListenOn)
	if err != nil {
		log.Fatal(err)
	}
	//2、实例化gRPC
	s := grpc.NewServer()
	//3、gRPC上注册服务
	pb.RegisterUserServiceServer(s, &server.UserService{}) // 空结构体 PersonService 就是在这里使用的
	pb.RegisterCompanyServiceServer(s, &server.CompanyService{})
	pb.RegisterApiServiceServer(s, &server.ApiService{})
	pb.RegisterDepartmentServiceServer(s, &server.DepartmentService{})

	//4、启动服务端
	s.Serve(listener)
}
